<template>
  <div class="page-body"   :style="c">
    <el-carousel  height="192.5px" @change="selectChange">
      <el-carousel-item  v-for="item in adForm" style="margin-top: 18px;height: 162.5px;border-radius: 5px">
        <img :src="item.thumbnail" width="100%" height="100%" style="border-radius: 5px">
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
  import {list} from '@/api/ad';
  import {mapGetters} from 'vuex';
  import utils from '../../../../utils/utils'
  export default {
    name: 'swipersChange',
    data(){
      return{
        index:'',
        c:'',
        pageNum: 1,
        pageSize: 3,
        color:'',
        tagIds:[],
        colors:[],
        adForm:[
          {thumbnail:'http://cdn.rzico.com/img/shuffling_img.jpeg'},
          {thumbnail:'http://cdn.rzico.com/img/shuffling_img.jpeg'},
          {thumbnail:'http://cdn.rzico.com/img/shuffling_img.jpeg'}
        ],
      }
    },
    methods:{
      selectChange(e){
        this.c=this.colors[e]
      },
      loadAd() {
        var _this = this
        if (!utils.isNull(this.content.tagids)) {
          this.tagIds = this.content.tagids.split(',');
          for (var i = 0; i < _this.tagIds.length; i++) {
            _this.tagIds[i] = parseInt(_this.tagIds[i])
          }
        }
        _this.pageSize = _this.content.rows;
        let params = new URLSearchParams();
        params.append('pageNum', _this.pageNum);
        params.append('pageSize', _this.pageSize);
        params.append('mchId', this.mchId);
        for (var i = 0; i < _this.tagIds.length; i++) {
          params.append('tagIds',_this.tagIds[i])
        }
        list(params).then(response => {
          response.data.data.forEach(item=>{
            _this.color="linear-gradient(180deg,"+item.backgroundColor+", rgba(248, 248, 248, 1))"
            let  backgrounds={
              background: _this.color
            }
            _this.colors.push(backgrounds)
          })
          this.c=_this.colors[0]
          if (!utils.isNull(response.data.data)){
            this.adForm = response.data.data;
            _this.adForm.forEach(function (item) {
              if (utils.isNull(item.thumbnail)){
                item.thumbnail='http://cdnx.hulu.fj.cn/upload/20200629/rBD_P17oiuSAYl2RAAQj40EPdu8011.png'
              }
              item.thumbnail = utils.thumbnail(item.thumbnail,750,360)
            })
          }
        }).catch(error => {
          console.log('error!!')
        });
      },
    },
    props:[
      'content'
    ],
    computed: {
      ...mapGetters([
        'mchId'
      ])
    },
    created() {
      this.loadAd()
    }

  }
</script>

<style scoped>


  .page_container {
    height: 100%;
    font-size: 32px;
    line-height: 1.6;
  }

  .page-body {
    padding-left: 20px;
    padding-right: 20px;
    /*margin-bottom:20px;*/
  }

  .page-section {
    width: 100%;
    margin-bottom: 60px;
  }

  .page-section_center {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .page-section:last-child {
    margin-bottom: 0;
  }

  .page-section-gap {
    box-sizing: border-box;
    padding: 0 30px;
  }

  .page-section-spacing {
    box-sizing: border-box;
    margin-top: 22px;
  }

  .page-section-title {
    font-size: 28px;
    color: #999999;
    margin-bottom: 10px;
    padding-left: 30px;
    padding-right: 30px;
  }

  .page-section-gap .page-section-title {
    padding-left: 0;
    padding-right: 0;
  }

  .demo-text-1 {
    position: relative;
    align-items: center;
    justify-content: center;
    background-color: #1AAD19;
    color: #FFFFFF;
    font-size: 36px;
  }

  .demo-text-1:before {
    content: 'A';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .demo-text-2 {
    position: relative;
    align-items: center;
    justify-content: center;
    background-color: #2782D7;
    color: #FFFFFF;
    font-size: 36px;
  }

  .demo-text-2:before {
    content: 'B';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .demo-text-3 {
    position: relative;
    align-items: center;
    justify-content: center;
    background-color: #F1F1F1;
    color: #353535;
    font-size: 36px;
  }

  .demo-text-3:before {
    content: 'C';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  button {
    margin-bottom: 30px;
  }

  button:last-child {
    margin-bottom: 0;
  }

  .page-section-title {
    padding: 0;
  }

  .swiper-item {
    display: block;
    height: 150px;
    border-radius: 16px;
  }

  .page-section-title {
    margin-top: 60px;
    position: relative;
  }

  .info {
    position: absolute;
    right: 0;
    color: #353535;
    font-size: 30px;
  }

  .page-foot {
    margin-top: 50px;
  }

  .under_text {
    margin-top: 25px;
    display: flex;
    height: 35px;
    padding-left: 25px;
    padding-right: 25px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
  }

  .under_text1 {
    width: 129px;
    height: 32px;
  }

  .under_text_2 {
    width: 136px;
    height: 32px;
  }

  .under_text_3 {
    width: 128px;
    height: 32px;
  }

  .title_content {
    height: 64px;
    width: 702px;
    display: flex;
  }

  .title_log {
    width: 28px;
    height: 34.5px;
  }

  .search_content {
    display: flex;
    height: 45px;
    align-items: center;
  }

  .search_input_content {
    width: 200px;
    height: 32px;
    border: 1px solid rgba(212, 215, 220, 1);
    opacity: 0.95;
    border-radius: 8px;
    display: flex;
    margin-left: 10px;
    align-items: center;
    background-color: white;
  }

  .icon_search {
    margin-left: 10px;
  }

  .icon {
    margin-left: 20px;
    font-size: 50px;
  }

  .cancel_text {
    font-size: 28px;
    font-weight: 400;
    color: rgba(26, 26, 30, 1);
    margin-top: 15px;
    margin-left: auto;
  }

  .search_input {
    width: 220px;
    height: 32px;
    margin-left: 7px;
    font-size: 14px;
    display: flex;
    align-items: center;
    font-weight: 400;
    color: rgba(26, 26, 30, 1);
    opacity: 0.89;
  }

  .icon_cancel {
    color: #D4D7DC;
    margin-left: 5px;
    opacity: 0.95;
  }
</style>
